package com.example.ying.controller;

import com.example.ying.common.R;
import com.example.ying.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class MovieController {
    @Autowired
    private MovieService movieService;

    // 返回所有电影
    @GetMapping("/movie")
    public R allMovie() {
        System.out.println("allMovie");
        return movieService.allMovie();
    }
    @GetMapping("/movie/category")
    public R getAllCategory() {
        return movieService.getAllCategory();
    }

    // 根据电影id返回电影详细信息
    @GetMapping("/movie/info")
    public R getInfoById(@RequestParam int id) {
        return movieService.getInfoById(id);
    }
    // 根据电影类别返回电影列表
    @GetMapping("/movie/info/category")
    public R getMovieByCategory(@RequestParam String category) {
        return movieService.getMovieByCategory(category);
    }

    // 根据豆瓣电影id返回电影详细信息
    @GetMapping("/movie/info/douban")
    public R getInfoBydoubanId(@RequestParam int id) {
        return movieService.getInfoBydoubanId(id);
    }

    @GetMapping("/movie/page")
    public R getMoviePage(@RequestParam int start) {
        return movieService.getMoviePage(start);
    }

    @GetMapping ("/movie/search")
    public R getMoviePage(@RequestParam String title) {
        return movieService.searchMovieByTitle(title);
    }

    //根据用户id进行电影推荐
    @GetMapping("/movie/recommend")
    public R getRecommendMovieByUserId(@RequestParam String userId) {
        return movieService.getRecommendMovieByUserId(userId);
    }

    @GetMapping("/movie/rated")
    public R getRatedMovieByUserId(@RequestParam String userId) {
        return movieService.getRatedMovieByUserId(userId);
    }
}
